	<?php $this->load->view('admin/partials/history_menu'); ?>
	<?php 
		$ci= &get_instance();
		$fromDate = $this->input->get('fromDate',TRUE);
		$toDate = $this->input->get('toDate',TRUE);
		$username = $this->input->get('username',TRUE);
		if(!$fromDate){
			$fromDate = 'From Date';
		}
		
		if(!$toDate){
			$toDate = 'To Date';
		}
		
		if(!$username){
			$username = 'Username';
		}
		$betResultArray = betResultDataConfig();
		
		$userEmailArray = array();
		foreach($ci->user_entity->getArrayListOfUser() as $item){
			$userEmailArray[] = '"'.$item->username.'"'; 
		}
	?>
		
	<div class="clrboth"></div>
	<script type="text/javascript">
		var username = [<?php echo implode(',',$userEmailArray);?>];
	</script>
	
	<h3>Bet history</h3>
	<div class="clrboth"></div>
	
	<div>
		<form id="mForm" accept-charset="utf-8" method="get" name="mForm" action="<?php echo site_url('admin/dataman/history/bet_manual');?>" >
			<input type="text" class="no-uniform" id="fromDate" name="fromDate" value="<?php echo $fromDate;?>" />				
			<input type="text" class="no-uniform" id="toDate" name="toDate" value="<?php echo $toDate;?>" />	
			<input type="text" class="no-uniform" id="username" name="username" value="<?php echo $username;?>" />		
			<input type="submit" value="Search" class="no-uniform" />	
		</form>	
	</div>
	<div class="clrboth"></div>
	<br/>
	<table border="0" class="table-list">
		<thead>
			<tr> 	 	 	 	
				<th>Username</th>
				<th>Category & Odds</th>
				<th>Answer</th>
				<th>Date/Time</th>
				<th>Match</th>
				<th>Stake</th>
				<th>Point</th>
				<th>Result</th>
			</tr>
		</thead>
		
		<tbody>
			<?php foreach( $items['records'] as $item ): ?>
			<?php 
				$MATCH = $ci->match_entity->init('id',$item->match_id);
				$HOME = clone_($ci->team_entity->init('id',$MATCH->getHome()));
				$AWAY = clone_($ci->team_entity->init('id',$MATCH->getAway()));
				$USER = $ci->user_entity->init('id',$item->user_id);
				$CAT_MANUAL = $ci->category_manual_entity->init('key_id',$item->category_id);
				$BET_MANUAL = clone_($ci->bet_manual_entity->init('id',$item->id));
			?>
			<tr>
				<td><?php echo $USER->getUserName(); ?></td>
				<td><?php echo $CAT_MANUAL->getCategoryName();?><br/>
					<?php echo $item->odds;?> Odds
				</td>
				<td>
					<?php 
						if($CAT_MANUAL->getType() == 'box'){
							$answer_array = array_filter(explode('{[|SEPSTR|]}',$BET_MANUAL->getAnswer()));
							foreach($answer_array as $one){
								echo "- ".$one."<br/>";
							}
						}else{
							$answer_array = array_filter(explode('{[|SEPSTR|]}',$BET_MANUAL->getAnswer()));
							echo "From ".$answer_array[0]." To ".$answer_array[1];
						}
					?>
				</td>
				<td><?php echo sysDateTimeFormat($item->bet_time,DATE_FM); ?></td>
				<td>
					<?php echo ( $HOME->getCode() ) ? $HOME->getCode() : $HOME->getName() ;?> Vs
					<?php echo ( $AWAY->getCode() ) ? $AWAY->getCode() : $AWAY->getName() ;?> <br/>
					ID: <?php echo $CAT_MANUAL->getKeyId() ;?>
				</td>
				<td><?php echo $item->stake;?></td>
				<td><?php echo $item->point_get;?></td>
				<td><?php echo $betResultArray[$item->result];?></td>
			</tr>
			<?php endforeach; ?>
		</tbody>
	</table>
	<div class="inner"><?php echo $items['pagination']['links'];?></div>

